package com.itouch.bracelet.adapter;

import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.itouch.bracelet.R;
import com.itouch.bracelet.bean.CircleInfo;
/**
 * 朋友圈适配器
 * @author Chenxi
 *
 */
public class PersonCircleAdapter extends BaseAdapter{

	private List<CircleInfo> mylist;
	private Context mContext;
	private LayoutInflater inflater;
	
	public PersonCircleAdapter(Context c,List<CircleInfo> list){
		
		mContext=c;
		inflater=LayoutInflater.from(c);
		mylist=list;
		
	}
	
	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return mylist.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		convertView=inflater.inflate(R.layout.person_circle_adapter, null);
		TextView date=(TextView) convertView.findViewById(R.id.day);
		TextView month=(TextView) convertView.findViewById(R.id.month);
		ImageView image=(ImageView) convertView.findViewById(R.id.image);
		TextView content=(TextView) convertView.findViewById(R.id.content);
		String time=mylist.get(position).getCreateTime();
		String st=time.substring(time.indexOf("-")+1);
		String m=st.substring(0,st.indexOf("-"));
		/*if(StringUtils.equals(m.substring(0,1), "0")){
			m=m.substring(1,2);
		}*/
		String d=st.substring(st.indexOf("-")+1,st.indexOf(" "));
		date.setText(d);
		month.setText(m+"月");
/*		if(StringUtils.isNotBlank(mylist.get(position).getImage())){
			BitmapUtils bu=CommonMethodTools.getBitmapUtil(mContext);
			BitmapDisplayConfig displayConfig = new BitmapDisplayConfig();
			displayConfig.setBitmapConfig(Bitmap.Config.RGB_565);
			displayConfig.setBitmapMaxSize(BitmapCommonUtils.getScreenSize(mContext));
			bu.display(image, mylist.get(position).getImage(), displayConfig);
		}else{
			image.setVisibility(View.GONE);
		}*/
		
/*
		ImageLoader loader=ImageLoader.getInstance();
		loader.displayImage(mylist.get(position).getPic(), image);//发帖人头像
*/		
		image.setVisibility(View.GONE);
		
		content.setText(mylist.get(position).getContent());
		convertView.setTag(mylist.get(position).getId()+"");
		return convertView;
	}

	public void updateData(List<CircleInfo> list){
		
		mylist.addAll(list);
		
	}

}
